package com.easyfun.healthmagicbox.comm.json;

import org.json.JSONException;
import org.json.JSONObject;

import com.easyfun.healthmagicbox.pojo.AlarmClock;


public class AlarmClockJsonWrapper <T extends JsonWrapper,E> 
						   			extends AbstractJsonWrapper<T,AlarmClock>
{
	public AlarmClockJsonWrapper(AlarmClock pp)
	{
		super(pp);
	}

	public AlarmClockJsonWrapper()
	{
		
	}
	
	@Override
	public void deserializeFromObj(JSONObject obj) throws JSONException {
		if (mpp==null)
		{
			mpp = new AlarmClock();
		}
		mpp.setPersonID(obj.getString("personID"));
		mpp.setCycle(obj.getString("cycle"));
		mpp.setDescription(obj.getString("description"));
		mpp.setStartTimeInMills(obj.getString("starttime"));
		mpp.setClockid(obj.getString("clockid"));
		mpp.setAnswer(obj.getString("answer"));
		mpp.setSyncid(obj.getString("id"));
	}

	@Override
	public JSONObject serializeToObj() throws JSONException {
		 JSONObject serializedObj = new JSONObject();
	     serializedObj.put("personID", mpp.getPersonID());
	     serializedObj.put("cycle", mpp.getCycle());
	     serializedObj.put("description", mpp.getDescription());
	     serializedObj.put("starttime", mpp.getStartTimeInMills());
	     serializedObj.put("answer", mpp.getAnswer());
	     serializedObj.put("clockid", mpp.getClockid());
	     
		return serializedObj;
	}

}
